import React, { lazy } from "react";
import { BrowserRouterProps } from "react-router-dom";
import dashboard from "./modules/dashboard";
import list from "./modules/list";
import room from "./modules/room";
import result from "./modules/result";
import user from "./modules/user";
import login from "./modules/login";
import otherRoutes from "./modules/others";
import notification from "./modules/notification";
export interface IRouter {
  path: string;
  redirect?: string;
  Component?: React.FC<BrowserRouterProps> | (() => any) | any;
  /**
   * 当前路由是否全屏显示
   */
  isFullPage?: boolean;
  /**
   * meta未赋值 路由不显示到菜单中
   */
  meta: {
    title?: string;
    Icon?: React.FC;
    /**
     * 侧边栏隐藏该路由
     */
    hidden?: boolean;
    /**
     * 单层路由
     */
    single?: boolean;
    /**
     * 路由访问所需角色
     */
    requiredRole: "admin" | "user";
  };
  children?: IRouter[];
}

const routes: IRouter[] = [
  {
    path: "/login",
    Component: lazy(() => import("pages/Login")),
    isFullPage: true,
    meta: {
      hidden: true,
      requiredRole: "user",
    },
  },
  {
    path: "/form/userreverse/notice",
    Component: lazy(() => import("pages/Form/UserReverse/Notice")),
    meta: {
      hidden: true,
      requiredRole: "user",
    },
  },
  {
    path: "/",
    meta: {
      requiredRole: "user",
      hidden: true, // 侧边栏隐藏该路由
    },
    redirect: "/dashboard",
  },
  // 配置404
  {
    path: "*",
    meta: {
      requiredRole: "user",
      hidden: true, // 侧边栏隐藏该路由
    },
    redirect: "/result/404",
  },
];

const allRoutes = [
  ...routes,
  ...dashboard,
  ...room,
  ...list,
  ...result,
  ...notification,
  ...user,
  ...login,
  ...otherRoutes,
];

export default allRoutes;
